const { defineConfig } = require('@vue/cli-service');
const path=require("path");

module.exports = defineConfig({
    transpileDependencies: true,
    css:{
        // loaderOptions:{
        //     // 单独配置scss或sass，配置scss语句结尾必须要有分号，配置sass语句结尾必须没有分号
        //     scss: {
        //         prependData: `@import "@/assets/scss/common.scss";`
        //     }
        // },
		sourceMap:true
    },
    configureWebpack:{
        resolve:{
            alias:{
                "@":path.resolve(__dirname,"src")
            }
        }
    },
    // 扩展webpack配置,使webpages加入编译
    chainWebpack: config => {
        // 全局使用scss
        const oneOfsMap = config.module.rule("scss").oneOfs.store;
        oneOfsMap.forEach((item) => {
            item
                .use("sass-resources-loader")
                .loader("sass-resources-loader")
                .options({
                    // resources:path.resolve(__dirname,"src/assets/scss/common.scss")
                    resources:"src/assets/scss/common.scss"
                })
                .end()
        });
        config.module
            .rule('js')
            .include.add(path.resolve(__dirname, 'packages')).end()
            .use('babel')
            .loader('babel-loader')
            .tap(options => {
                return options
            });
    }
});